[ykj_id].vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  1. <script setup>
  2. import { useRouter } from 'vue-router'
  3. import request from '~/utils/request'
  4. const router = useRouter()
  5. const route = useRoute()
  6. function linkTo(obj) {
  7. router.push(obj)
  8. }
  9. let ykj_id = $ref('')
  10. const keyword = $ref('')
  11. const limit = $ref(10)
  12. let total = $ref(0)
  13. let cur_page = $ref(1)
  14. let listData = $ref([])
  15. let dialogVisible = $ref(false)
  16. let title = $ref('')
  17. let is_edit = $ref(false)
  18. let project = $ref({})
  19. let subject = $ref([])
  20. let subject_list = $ref([])
  21. let teacher = $ref({
  22. value: '',
  23. label: '',
  24. user_realname: '',
  25. })
  26. let yj_id = $ref('')
  27. let teacher_list = $ref([])
  28. function getListData() {
  29. request({
  30. url: '/yzy/jyy/index',
  31. data: {
  32. ykj_id,
  33. keyword,
  34. page: cur_page,
  35. limit,
  36. },
  37. }).then((res) => {
  38. if (res.code === '1') {
  39. listData = res.data.page_data
  40. total = Number(res.data.total_rows)
  41. cur_page = Number(res.data.page_now)
  42. }
  43. })
  44. }
  45. function getProjectInfo() {
  46. const data = {
  47. ykj_id,
  48. }
  49. request({
  50. url: '/yzy/ksjh/detail',
  51. data,
  52. }).then((res) => {
  53. if (res.code === '1') {
  54. project = res.data.one_info
  55. subject_list = project.lc
  56. gerUsers()
  57. }
  58. })
  59. }
  60. function filterData() {
  61. cur_page = 1
  62. getListData()
  63. }
  64. function handleSelectionChange(val) {
  65. cur_page = val
  66. getListData()
  67. }
  68. function addTeacher() {
  69. is_edit = false
  70. subject = []
  71. title = '增加教研员'
  72. dialogVisible = true
  73. teacher = {
  74. value: '',
  75. label: '',
  76. user_realname: '',
  77. }
  78. }
  79. function gerUsers() {
  80. request({
  81. url: `${window.GLOBAL_CONFIG.uc}/user/main/teachers`,
  82. data: {
  83. // sm_id: project.ykj_lkxx,
  84. // user_role_id: user.user_role_id,
  85. page: '1',
  86. limit: '9999',
  87. },
  88. }).then((res) => {
  89. if (res.code === '1')
  90. teacher_list = res.data.page_data
  91. })
  92. }
  93. function editTeacher(item) {
  94. is_edit = true
  95. title = '编辑教研员'
  96. teacher = {
  97. value: item.yj_user_id,
  98. label: item.yj_username,
  99. user_realname: item.yj_realname,
  100. }
  101. yj_id = item.yj_id
  102. subject = []
  103. for (const i in item.yj_subject_id.split(',')) {
  104. const obj = {
  105. value: item.yj_subject_id.split(',')[i],
  106. label: item.yj_subject_name.split(',')[i],
  107. }
  108. subject.push(obj)
  109. }
  110. dialogVisible = true
  111. }
  112. function del_teacher(item) {
  113. ElMessageBox.confirm('确认删除该教研员?', '', {
  114. confirmButtonText: '确认',
  115. cancelButtonText: '取消',
  116. type: 'warning',
  117. }).then(() => {
  118. request({
  119. url: '/yzy/jyy/delete',
  120. data: {
  121. yj_id: item.yj_id,
  122. },
  123. }).then((res) => {
  124. if (res.code === '1') {
  125. ElMessage({
  126. type: 'success',
  127. message: '删除成功',
  128. })
  129. getListData()
  130. }
  131. })
  132. })
  133. }
  134. function handleSubmit() {
  135. const subject_ids = []
  136. const subject_names = []
  137. for (const i in subject) {
  138. subject_ids.push(subject[i].value)
  139. subject_names.push(subject[i].label)
  140. }
  141. if (!is_edit) {
  142. request({
  143. url: '/yzy/jyy/add',
  144. data: {
  145. issubmit: '1',
  146. yzy_jyy: {
  147. ykj_id,
  148. yj_user_id: teacher.value,
  149. yj_realname: teacher.user_realname,
  150. yj_username: teacher.label,
  151. yj_subject_id: subject_ids.join(','),
  152. yj_subject_name: subject_names.join(','),
  153. },
  154. },
  155. }).then((res) => {
  156. if (res.code === '1') {
  157. ElMessage.success('教研员添加成功!')
  158. dialogVisible = false
  159. getListData()
  160. }
  161. })
  162. }
  163. else {
  164. request({
  165. url: '/yzy/jyy/edit',
  166. data: {
  167. issubmit: '1',
  168. yj_id,
  169. yzy_jyy: {
  170. ykj_id,
  171. yj_user_id: teacher.value,
  172. yj_realname: teacher.user_realname,
  173. yj_username: teacher.label,
  174. yj_subject_id: subject_ids.join(','),
  175. yj_subject_name: subject_names.join(','),
  176. },
  177. },
  178. }).then((res) => {
  179. if (res.code === '1') {
  180. ElMessage.success('教研员编辑成功!')
  181. dialogVisible = false
  182. getListData()
  183. }
  184. })
  185. }
  186. }
  187. if (route.params.ykj_id) {
  188. ykj_id = route.params.ykj_id
  189. getListData()
  190. getProjectInfo()
  191. }
  192. </script>
  193. <route lang="json">
  194. {
  195. "meta":{
  196. "title":"教研员设置",
  197. "breadcrumb":true
  198. }
  199. }
  200. </route>
  201. <template>
  202. <NavHeader />
  203. <bread-crumb />
  204. <div class="w-1200px m-auto">
  205. <div class="relative -mt-40px flex justify-end">
  206. <button type="button" class="back-btn" @click="linkTo({ name: 'process' })">
  207. 返回
  208. </button>
  209. </div>
  210. <div class="mt-10px w-full bg-hex-fff min-h-700px py-20px px-15px">
  211. <div class="flex align-center">
  212. <el-input
  213. v-model="keyword"
  214. class="ml-20px"
  215. style="width: 225px;"
  216. size="large"
  217. clearable
  218. placeholder="请输入关键字"
  219. @keyup.enter="filterData"
  220. @clear="filterData"
  221. />
  222. <el-button color="#003eee" class="ml-10px" type="primary" size="large" @click="filterData">
  223. 搜索
  224. </el-button>
  225. <button type="button" class="ml-10px add-btn" @click="addTeacher">
  226. <el-icon class="inline-block align-middle">
  227. <Plus />
  228. </el-icon>
  229. <span class="ml-5px inline-block align-middle">新增教研员</span>
  230. </button>
  231. </div>
  232. <h3 class="mt-20px mb-10px text-13px text-hex-6F6F6F">
  233. (此处为查看扫描批阅进度的权限赋予设置)
  234. </h3>
  235. <div v-if="listData.length > 0">
  236. <table class="data-table" cellpadding="0" cellspacing="0">
  237. <tr>
  238. <th>教研员名称</th>
  239. <th>教研员账号</th>
  240. <th>权限科目</th>
  241. <th>操作</th>
  242. </tr>
  243. <tr v-for="item in listData">
  244. <td>{{ item.yj_realname }}</td>
  245. <td>{{ item.yj_username }}</td>
  246. <td>{{ item.yj_subject_name }}</td>
  247. <td>
  248. <button type="button" class="op-btn edit" @click="editTeacher(item)">
  249. 编辑
  250. </button>
  251. <button type="button" class="ml-15px op-btn del" @click="del_teacher(item)">
  252. 删除
  253. </button>
  254. </td>
  255. </tr>
  256. </table>
  257. <div class="mt-20px page-new flex justify-end">
  258. <el-pagination
  259. v-model:current-page="cur_page" v-model:page-size="limit" layout="total,prev, pager, next"
  260. :total="total" :background="true" @current-change="handleSelectionChange"
  261. />
  262. </div>
  263. </div>
  264. <div v-else class="no-data">
  265. <div>
  266. <h3 class="no-data-img" />
  267. <h4 class="mt-25px text-18px text-hex-0048e5 text-center">
  268. 暂无数据
  269. </h4>
  270. </div>
  271. </div>
  272. </div>
  273. </div>
  274. <commonFooter />
  275. <el-dialog
  276. v-model="dialogVisible"
  277. :title="title"
  278. width="500px"
  279. append-to-body
  280. >
  281. <div>
  282. <el-form label-width="120px" size="large">
  283. <el-form-item label="教研员">
  284. <el-select v-model="teacher" placeholder="请选择教研员" filterable style="width: 100%">
  285. <el-option
  286. v-for="item in teacher_list" :label="`${item.user_realname} - ${item.user_name}`"
  287. :value="{ value: item.user_id, label: item.user_name, user_realname: item.user_realname }"
  288. />
  289. </el-select>
  290. </el-form-item>
  291. <el-form-item label="可查看学科">
  292. <el-select v-model="subject" placeholder="请选择学科" multiple filterable style="width: 100%">
  293. <el-option
  294. v-for="item in subject_list" :value-key="item.ze_xueke" :label="item.ze_xueke_name"
  295. :value="{ value: item.ze_xueke, label: item.ze_xueke_name }"
  296. />
  297. </el-select>
  298. </el-form-item>
  299. <div class="mt-40px text-center">
  300. <el-button class="mr-30px" @click="dialogVisible = false">
  301. 取消
  302. </el-button>
  303. <el-button
  304. type="primary" color="#003eee" :disabled="teacher.value === '' || subject.length === 0"
  305. @click="handleSubmit"
  306. >
  307. 确定
  308. </el-button>
  309. </div>
  310. </el-form>
  311. </div>
  312. </el-dialog>
  313. </template>
  314. <style scoped lang="scss">
  315. $color: #0048e5;
  316. ::v-deep .el-pagination.is-background .btn-next.is-active,
  317. ::v-deep .el-pagination.is-background .btn-prev.is-active,
  318. ::v-deep .el-pagination.is-background .el-pager li.is-active {
  319. background-color: $color;
  320. }
  321. .add-btn {
  322. width: 129px;
  323. height: 40px;
  324. background: #ffffff;
  325. border: 1px solid $color;
  326. border-radius: 4px;
  327. font-size: 14px;
  328. color: $color;
  329. text-align: center;
  330. .el-icon {
  331. font-size: 16px;
  332. }
  333. }
  334. .data-table {
  335. width: 100%;
  336. table-layout: fixed;
  337. tr:nth-child(even) {
  338. background: #F1F7FF;
  339. }
  340. th {
  341. height: 50px;
  342. background: $color;
  343. font-weight: normal;
  344. text-align: center;
  345. font-size: 16px;
  346. color: #fff;
  347. &:first-child {
  348. border-radius: 6px 0 0 0;
  349. }
  350. &:last-child {
  351. border-radius: 0 6px 0 0;
  352. }
  353. }
  354. td {
  355. padding: 15px 0;
  356. font-size: 16px;
  357. color: #474747;
  358. text-align: center;
  359. }
  360. }
  361. .op-btn {
  362. width: 56px;
  363. height: 30px;
  364. background: #ffffff;
  365. font-size: 14px;
  366. border-radius: 2px;
  367. &.edit {
  368. border: 1px solid $color;
  369. color: $color;
  370. }
  371. &.del {
  372. border: 1px solid #E50101;
  373. color: #E50101;
  374. }
  375. }
  376. .no-data {
  377. width: 100%;
  378. height: 450px;
  379. display: flex;
  380. justify-content: center;
  381. align-items: center;
  382. .no-data-img {
  383. width: 233px;
  384. height: 199px;
  385. background: url("/images/no-data.png") center no-repeat;
  386. }
  387. }
  388. </style>